package com.ytjj.qmyx.admin.controller;

import com.ytjj.common.api.CommonResult;
import com.ytjj.qmyx.admin.annotation.OperLog;
import com.ytjj.qmyx.admin.constants.SysLogConstants;
import com.ytjj.qmyx.admin.model.request.DynamicTopicRequest;
import com.ytjj.qmyx.admin.service.DynamicTopicService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 *
 * 
 * @description:测评话题
 */
@Slf4j
@RestController
@RequestMapping("/dynamicTopicController")
public class DynamicTopicController {


    @Autowired
    private DynamicTopicService dynamicTopicService;

    @PostMapping("/addOrEditTopic")
    @OperLog(operModule = "话题模块", operDesc = "修改或新增话题信息", operType = SysLogConstants.OPERATION_UPDATE+"或者"+SysLogConstants.OPERATION_ADD)
    public CommonResult addOrEditTopic(@RequestBody DynamicTopicRequest dynamicTopicRequest){
        int count = dynamicTopicService.addOrEditTopic(dynamicTopicRequest);
        return CommonResult.success(count);
    }

    @GetMapping("/setOffOrOnForTopic")
    @OperLog(operModule = "话题模块", operDesc = "话题上下架", operType = SysLogConstants.OPERATION_UPDATE)
    public CommonResult setOffOrOnForTopic(Integer id,Integer status){
        return  CommonResult.success(dynamicTopicService.setOffOrOnForTopic(id,status));
    }

    @PostMapping("/getDynamicTopicDetails")
    @OperLog(operModule = "话题模块", operDesc = "查询话题列表", operType = SysLogConstants.OPERATION_SELECT)
    public CommonResult getDynamicTopicDetails(@RequestBody DynamicTopicRequest dynamicTopicRequest){
        return  CommonResult.success(dynamicTopicService.getDynamicTopicDetails(dynamicTopicRequest));
    }

    @GetMapping("/getAllDynamicTopics")
    @OperLog(operModule = "话题模块", operDesc = "根据标题获取话题", operType = SysLogConstants.OPERATION_SELECT)
    public CommonResult getAllDynamicTopics(String title){
        return  CommonResult.success(dynamicTopicService.getAllTopic(title));
    }

    @GetMapping("/getSomeTopicPvTop")
    @OperLog(operModule = "话题模块", operDesc = "获得话题排行列表", operType = SysLogConstants.OPERATION_SELECT)
    public CommonResult getSomeTopicPvTop(){
        return  CommonResult.success(dynamicTopicService.getTopicsTop());
    }

    @GetMapping("/getTopicInfoAndPvById")
    @OperLog(operModule = "话题模块", operDesc = "根据话题Id查询话题及pv数信息", operType = SysLogConstants.OPERATION_SELECT)
    public CommonResult getTopicInfoAndPvById(@RequestParam Integer id){
        return  CommonResult.success(dynamicTopicService.getTopicInfoAndPvById(id));
    }

    @GetMapping("/getTopicInfoList")
    @OperLog(operModule = "话题模块", operDesc = "获取所有话题", operType = SysLogConstants.OPERATION_SELECT)
    public CommonResult getTopicInfoList(){
        return  CommonResult.success(dynamicTopicService.getTopicInfoList());
    }


}
